package main;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JTextPane;

import commans.ErrorPage;

import car.CarPolicyPrint;
import far.FirePolicyPrintBeta;
import frame.CarPolicyFrame;
import frame.FirePolicyFrame;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/*
 * 
 * 
 * 
 * 程式進入點
 * 
 * 
 * */
public class MainFrame extends JFrame
{

    private static JPanel contentPane;
    private static boolean showboxflag = true;

    public void SetOpenBoxFlag(boolean flag)
    {
        this.showboxflag = true;
    }

    public MainFrame() throws Exception
    {
        setResizable(false);
        setTitle("要保書列印程式");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100,100,281,92);
        setLocationRelativeTo(null); // 視窗至中
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5,5,5,5));
        setContentPane(contentPane);
        contentPane.setLayout(null);
        JButton btnNewButton = new JButton("火險");
        btnNewButton.setBounds(41,13,89,25);
        contentPane.add(btnNewButton);

        JButton btnNewButton_3 = new JButton("\u8ECA\u96AA");
        btnNewButton_3.setBounds(147,13,89,25);
        contentPane.add(btnNewButton_3);
        btnNewButton_3.addActionListener(new ActionListener()
        {
	  public void actionPerformed(ActionEvent e)
	  {
	      if(showboxflag)
	      {
		new CarPolicyFrame();
		showboxflag = false;
	      }
	  }
        });
        btnNewButton.addActionListener(new ActionListener()
        {
	  public void actionPerformed(ActionEvent e)
	  {
	      if(showboxflag)
	      {
		new FirePolicyFrame();
		showboxflag = false;
	      }
	  }
        });
    }

    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
	  public void run()
	  {
	      try
	      {
		MainFrame frame = new MainFrame();
		frame.setVisible(true);
	      }
	      catch (Exception e)
	      {
		new ErrorPage(e);
	      }
	  }
        });
    }

}
